<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登入 - 后台管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <#include "/include/layui-top.html">
  <link rel="stylesheet" href="/components/layuiadmin/style/login.css" media="all">
</head>
<body>

  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>${((boss_title!'')?length>0)?string((boss_title!''),'探程农业项目后台')}</h2>
        <p>xxxx后台（自用）</p>
      </div>
      <#import "/spring.ftl" as spring/>
      <form class="content" id="login-form" action="javascript:;">
          <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
              <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
              <input type="text" name="userName" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input" value="${loginForm.userName!}">
            </div>
            <div class="layui-form-item">
              <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
              <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input" value="${loginForm.password!}">
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
              <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住密码">
              <a href="javascript:;" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <input name="refer" hidden value="${loginForm.refer!}"/>
              <button id="login-btn" class="layui-btn layui-btn-fluid">登 入</button>
            </div>
          </div>
      </form>
      
      
      
    </div>
    
    <div class="layui-trans layadmin-user-login-footer">
      
      <p>© 2020 - <span>${.now?string["yyyy"]}</span><a href="https://probe.cc/" target="_blank">probe.cc</a></p>
      <p>Power by <a href="https://search.maven.org/search?q=g:%22org.springframework.boot%22%20a:%22spring-boot-starter-parent%22" target="_blank">Springboot v${springBootVersion!}</a>, layui <span id="layui-version"></span></p>
      <p>
        <span><a href="https://www.huobi.sh/zh-cn/" target="_blank">火币全球站</a></span>
        <span><a href="https://www.binancezh.co/" target="_blank">币安网</a></span>
        <span><a href="https://probe.cc/" target="_blank">探针官网</a></span>
      </p>
    </div>
    
  </div>

  <#include "/include/layui-end.html">
  <script>
  layui.config({
        base: '/components/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
    var $ = layui.$
    ,setter = layui.setter
    ,admin = layui.admin
    ,form = layui.form
    ,router = layui.router()
    ,search = router.search;
    
    $('#layui-version').text('v'+layui.v);

    form.render();
    
    $('#captcha').click(function(){
        refreshcap();
    });
    
    $('#login-btn').click(function(){
        var formData = $('#login-form').serializeArray();
        var submitData = {};
        $.each(formData, function(index, field){
            if(field.name == "rememberMe" && field.value == "on"){
                submitData[field.name] = true;
            } else {
                submitData[field.name] = field.value;
            }
        });
        $.ajax({
            type: 'POST',
            url: '/boss/login',
            data: JSON.stringify(submitData),
            success: function (data) {
                if(!data.success){
                    layer.msg(data.message);
                    refreshcap();
                }
                if(data.showCaptcha){
                    $('#captcha-item').removeClass('layui-hide');
                    $('#showCaptcha').val(true);
                }
                if(data.success){
                    layer.msg('登录成功');
                    if(data.requestPath != '' && data.requestPath != null){
                        location.href = data.requestPath;
                    } else {
                        location.href='/boss/main';
                    }
                }
            },
            error: function(data) {
                var result = JSON.parse(data.responseText);
                layer.msg(result.message);
            },
            contentType: "application/json;charset=utf-8"
        });
    });
    
    function refreshcap(){
           $('#captcha').attr('src','/boss/captcha.jpg?s='+Math.random());
           $('#LAY-user-login-vercode').val('');
    }
  });
  
  </script>
</body>
</html>